package com.lipy.lock.distributed.redis;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lipye
 */
@Configuration
public class RedissonConfig {

    /**
     * ip:port
     */
    @Value("${redis.url}")
    private String redisUrl;

    @Bean(name = "redissonClient")
    public RedissonClient redissonClient(){
        Config config = new Config();
        config.useSingleServer().setAddress("redis://"+redisUrl)
                .setConnectionPoolSize(1000)
                .setConnectionMinimumIdleSize(100);
//                .setPassword()
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }

}
